blob: fb78b771f5ce17aa05377b67545654a7313e26c9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import getRates from "$lib/rates";
import { auth, get } from "$lib/utils";
// Funds are discontinued: the page is a read-only view of a fund's history.
// Fetch with the viewer's token so a manager opening a pre-rotation link is
// served the rotated fund, and fall back to a "discontinued" notice instead of
// the generic error page when the fund can't be shown.
export const load = async ({ cookies, depends, params: { id }, parent }) => {
depends("app:payments");
const { user } = await parent();
const headers = user ? auth(cookies) : {};
let data;
try {
data = await get(`/fund/${id}`, headers);
data.managers = await get(`/fund/${data.id || id}/managers`);
} catch (e) {
data = { notFound: true, amount: 0, payments: [], managers: [] };
}
const rates = await getRates();
data.rate = rates[user?.currency || "USD"];
return data;
};
|